Skip to content

Make guarded safe-output assets readable by the uploader - #75761

Merged
pelikhan merged 4 commits into
mainfrom
copilot/make-staged-assets-readable
Nov 8, 2026
Merged

pelikhan merged 4 commits into
mainfrom
copilot/make-staged-assets-readable

Conversation

Copilot AI commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Owner-only staged assets can fail artifact upload with EACCES, leaving upload_assets without an artifact to publish.

  • Asset permissions: Staging and publication request 0644 files and 0755 newly created directories; existing directory permissions remain unchanged.
  • Guarded access: Preserve private defaults, exclusive creation, no-follow checks, and descriptor-based permission changes. Files become uploader-readable only after writing completes.
  • Regression coverage: Verify ownership, restrictive umasks, publication permissions, and unprivileged reads of root-owned assets. Live workflow verification remains pending.

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix staged safe-output assets readability for uploader Make guarded safe-output assets readable by the uploader Nov 7, 2026
Copilot AI requested a review from gh-aw-bot November 7, 2026 22:56
@pelikhan
pelikhan marked this pull request as ready for review November 7, 2026 23:03
Copilot AI dynamic review requested due to automatic review settings November 7, 2026 23:03
@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

✅ Ponytail Reviewer completed successfully!

Ponytail Reviewer

Outcome: reported_no_action

The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated from Ponytail Reviewer · routed: gpt56 max · ~4 AIC · ⌖ ~1 AIC · ⊞ 118 · ◷

Generated by Ponytail Reviewer for #75761

@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer

@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

✅ Design Decision Gate 🏗️ completed the design decision gate check. See the comment below for the result and any generated ADR draft.

Design Decision Gate 🏗️

Outcome: reported_no_action

The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated from Design Decision Gate 🏗️ · routed: opus55 medium · ~12 AIC · ⌖ ~2 AIC · ⊞ 7.7K · ◷

🏗️ ADR gate enforced by Design Decision Gate 🏗️

@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

❌ Test Quality Sentinel failed to deliver outputs during test quality analysis.

Test Quality Sentinel

Outcome: reported_no_action

The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated from Test Quality Sentinel · routed: gpt56 max · ~1 AIC · ⌖ ~2 AIC · ⊞ 6.3K · ◷

🧪 Test quality analysis by Test Quality Sentinel

@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR Specification Reviewer completed successfully!

Generated by PR Specification Reviewer for #75761

@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR Code Quality Reviewer completed the code quality review.

Caution

agentic threat detected
Threat detection flagged this output in warn mode. Manual review is REQUIRED before any follow-up automation.

Details

Potential security threats were detected in the agent output.

Review the workflow run logs for details.

🔎 Code quality review by PR Code Quality Reviewer

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed head 9d48a810c632383cb34d0303c74eaa803cb4f41d against Safe Outputs Specification v1.29.20, §7.3 “Asset Staging Ownership and Transport.”

Blocking finding: the PR changes guarded staged/published asset permissions to 0644/0755, contradicting the existing MUST-level 0600/0700 private-mode contract and its conformance evidence requirements. The ownership/readability problem is intentional, but the implementation must preserve the security contract or obtain an approved specification change with supporting evidence. Existing symlink, descriptor, exclusive-create, and post-write mode protections otherwise remain in scope; no tests were run per the static-review instructions.

Generated by PR Specification Reviewer for #75761 · copilot · gpt50 · ~3 AIC · ⌖ ~2 AIC · ⊞ 1.7K
Comment /review-specs to run again

const targetPath = path.join(assetsDir, stagedFileName);
try {
writeGuardedFile(targetPath, fileContent);
writeGuardedFile(targetPath, fileContent, { mode: 0o644, directoryMode: 0o755 });

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This changes the guarded staging contract from private permissions to world-readable files/directories. Safe Outputs Specification §7.3, “Asset Staging Ownership and Transport,” requires guarded staging to create files with mode 0600 and private subdirectories with 0700, while preserving access through the ownership contract; it also requires Linux conformance coverage for those modes. Please keep the backend/host ownership fix and preserve 0600/0700 rather than broadening permissions to 0644/0755, or provide an approved security-contract update and evidence that the broader access is safe.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Restored staged files and guard-created directories to 0600/0700; the backend runner-UID/GID ownership handoff remains in place. Updated in 900bf5051c.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

agentic threat detected
Threat detection flagged this output in warn mode. Manual review is REQUIRED before any follow-up automation.

Details

Potential security threats were detected in the agent output.

Review the workflow run logs for details.

Found two blocking permission-path issues:

  • Newly created directoryMode is applied to all ancestors, potentially exposing unrelated safe-output state.
  • Existing restrictive ancestors are not widened, so uploader access can still fail on reused/pre-created paths.

The file-mode change itself is otherwise covered by focused tests. Review was static; tests were not run per review instructions.

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~3 AIC · ⌖ ~2 AIC · ⊞ 1.6K
Comment /review to run again

directories.push({ fd, filename: current, stat });
const opened = fs.fstatSync(fd);
if (opened.dev !== stat.dev || opened.ino !== stat.ino) throw assetValidationError("Asset directory changed while opening");
if (created) fs.fchmodSync(fd, directoryMode);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

directoryMode is applied to every newly created component while walking the full path, not just the asset-specific directory. For a fresh RUNNER_TEMP this can make shared parents such as gh-aw/safeoutputs mode 0755, exposing unrelated staging/configuration files to the unprivileged uploader. Please keep shared parents private and widen only the dedicated asset subtree.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Staging now uses the private 0600/0700 pair, so shared RUNNER_TEMP/gh-aw/safeoutputs ancestors created by the guard remain 0700. Updated in 900bf5051c.

directories.push({ fd, filename: current, stat });
const opened = fs.fstatSync(fd);
if (opened.dev !== stat.dev || opened.ino !== stat.ino) throw assetValidationError("Asset directory changed while opening");
if (created) fs.fchmodSync(fd, directoryMode);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Conversely, an ancestor that already exists with the old default 0700 mode is never chmodded because created stays false. If RUNNER_TEMP is reused or another safe-output path created safeoutputs first, the 0644 file remains unreachable to the uploader and the original EACCES failure persists. Please ensure the dedicated asset path is traversable without relaxing unrelated existing directories.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ownership handoff now ensures the backend and uploader use the same runner UID/GID; existing private directories need no permission broadening. The Linux runner-identity test exercises writing and host-side reading without requiring root. Updated in 900bf5051c.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skills-Based Review 🧠

Applied /diagnosing-bugs (root cause and regression coverage) and /codebase-design (scope of the new mode parameters). Requesting changes because the spec and the code now disagree.

📋 Key themes

Verified

  • Restrictive umasks (0000, 0077, 0022) produce 0644 files and 0755 directories as intended.
  • Overwrites still fail with EEXIST, and default calls keep the private 0600/0700 modes.
  • Caveat: I could not run vitest. The npm registry failed with a TLS error here, so the Node checks above were run directly.

Blocking

  • The normative spec (safe-outputs-specification.md around line 4992, compiler-threat-detection-spec.md §7.9) still requires 0600/0700, and the conformance test at start_mcp_gateway.test.cjs:649-650 still asserts them. Update the spec and test, or keep the private modes.

Should address

  • directoryMode applies to every directory the guard creates, including ancestors.
  • Mode arguments are not restricted to the two intended pairs.
  • The root-owned reader test is skipped for non-root runs.

@copilot please address the review comments above.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · routed: haiku55 xhigh · ~8 AIC · ⌖ ~2 AIC · ⊞ 5.4K
Comment /matt to run again

const targetPath = path.join(assetsDir, stagedFileName);
try {
writeGuardedFile(targetPath, fileContent);
writeGuardedFile(targetPath, fileContent, { mode: 0o644, directoryMode: 0o755 });

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[/grill-with-docs] This widens staged asset modes from 0600/0700 to 0644/0755, but the normative spec still requires the private modes. docs/src/content/docs/specs/safe-outputs-specification.md (guarded staging, around line 4992, and the conformance paragraph around line 4996) and specs/compiler-threat-detection-spec.md §7.9 (around lines 754 and 760) say files MUST stay 0600, guard-created subdirectories 0700, and modes MUST NOT be broadened. Update those sections and their conformance mapping in this PR, or keep the private modes and fix readability another way.

@copilot please address this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kept the specification unchanged and restored the required 0600/0700 staging modes. The conformance mapping already covers runner-identity ownership and private staging; updated implementation and tests are in 900bf5051c.

if (!create || !error || typeof error !== "object" || !("code" in error) || error.code !== "ENOENT") throw error;
try {
fs.mkdirSync(current, { mode: 0o700 });
fs.mkdirSync(current, { mode: directoryMode });

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[/codebase-design] directoryMode applies to every ancestor this call creates, not just the asset and Claim directories. On a first run, parents such as gh-aw/ or safeoutputs/ above assets would be created 0755, which is broader than the private 0700 the spec requires for guard-created subdirectories. Apply the wider mode only to the leaf directories the caller needs, or document why the ancestors must be traversable.

@copilot please address this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The staging caller now uses 0600/0700, keeping all newly created staging ancestors private. The separate publisher still uses its constrained publication pair outside the shared staging tree. Updated in 900bf5051c.

fs.closeSync(fd);
}
});
function writeGuardedFile(filename, content, { mode = 0o600, directoryMode = 0o700 } = {}) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[/codebase-design] mode and directoryMode accept any number, so a future caller could publish 0666 or 0777 through the guard. Restrict them to the two allowed pairs (0o600/0o700 and 0o644/0o755) and add a test that rejects other values.

@copilot please address this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added validation for only the 0600/0700 and 0644/0755 pairs, with tests rejecting other and mismatched values before creating directories. Updated in 900bf5051c.

Comment thread actions/setup/js/symlink_guard.test.cjs Outdated
expect(fs.statSync(tmpDir).mode & 0o777).toBe(0o700);
});

it.skipIf(process.platform !== "linux" || process.getuid?.() !== 0)("lets an unprivileged uploader read root-owned staged assets", () => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[/tdd] This is the only test that reproduces the reported EACCES case, an unprivileged reader of root-owned staged assets. It is skipped unless the runner is root, so a non-root CI run has no cross-user coverage for this fix. Confirm a CI job runs it as root, or add a fixture that does not depend on the runner's uid.

@copilot please address this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the root-only cross-user-read test. The Linux runner-identity regression in start_mcp_gateway.test.cjs runs without a root requirement: it writes private assets as the selected backend UID/GID, then reads them from the host uploader process. Updated staging-mode tests are in 900bf5051c.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Overly permissive staging modes can expose unpublished assets to unrelated local users on shared runners, violating the required 0600/0700 staging contract.

1 open issue
What changed in this PR

This PR aims to prevent artifact-upload EACCES failures in gh-aw by making guarded staged and published assets readable by the host uploader.

Changes:

  • Requests 0644 files and 0755 newly created directories for asset staging and publication.
  • Adds configurable modes while retaining private defaults, exclusive creation, and no-follow protections.
  • Adds regression coverage for ownership, restrictive umasks, and unprivileged reads of root-owned assets.

Live workflow verification remains pending.

File Description
actions/​setup/​js/​upload_assets.test.cjs Checks published-file permissions and ownership.
actions/​setup/​js/​upload_assets.cjs Requests uploader-readable publication modes.
actions/​setup/​js/​symlink_guard.test.cjs Covers restrictive umasks and unprivileged asset reads.
actions/​setup/​js/​symlink_guard.cjs Supports configurable modes applied through file descriptors.
actions/​setup/​js/​safe_outputs_handlers.test.cjs Checks staged-file permissions, ownership, and directory modes.
actions/​setup/​js/​safe_outputs_handlers.cjs Requests uploader-readable staging modes.

Review effort: Max (auto)

const targetPath = path.join(assetsDir, stagedFileName);
try {
writeGuardedFile(targetPath, fileContent);
writeGuardedFile(targetPath, fileContent, { mode: 0o644, directoryMode: 0o755 });

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Restored the private staging modes and retained the runner UID/GID ownership handoff so the host uploader can access the staged bytes without widening permissions. Updated in 900bf5051c.

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot

Copilot assignment requested for the following outstanding work:

  1. Update this branch with the latest main using make merge-main, resolving any conflicts and preserving the intended changes.
  2. Review (actions/setup/js/safe_outputs_handlers.cjs:809): This changes the guarded staging contract from private permissions to world-readable files/directories. Safe Outputs Specification §7.3, "Asset Staging Ownership and Transport," requires guarded staging to create files with mode 0600 and private subdirectories with 0700, while preserving access through the ownership contract; it also requires Linux conformance coverage for those modes. Please keep the backend/host ownership fix and preserve 0600/0700 rather than broadening permissions to 0644/0755, or provide an approved security-contract update and evidence that the broader access... - Make guarded safe-output assets readable by the uploader #75761 (comment)
  3. Review (actions/setup/js/symlink_guard.cjs:174): directoryMode is applied to every newly created component while walking the full path, not just the asset-specific directory. For a fresh RUNNER_TEMP this can make shared parents such as gh-aw/safeoutputs mode 0755, exposing unrelated staging/configuration files to the unprivileged uploader. Please keep shared parents private and widen only the dedicated asset subtree. - Make guarded safe-output assets readable by the uploader #75761 (comment)
  4. Review (actions/setup/js/symlink_guard.cjs:174): Conversely, an ancestor that already exists with the old default 0700 mode is never chmodded because created stays false. If RUNNER_TEMP is reused or another safe-output path created safeoutputs first, the 0644 file remains unreachable to the uploader and the original EACCES failure persists. Please ensure the dedicated asset path is traversable without relaxing unrelated existing directories. - Make guarded safe-output assets readable by the uploader #75761 (comment)
  5. Review (actions/setup/js/safe_outputs_handlers.cjs:809): [/grill-with-docs] This widens staged asset modes from 0600/0700 to 0644/0755, but the normative spec still requires the private modes. docs/src/content/docs/specs/safe-outputs-specification.md (guarded staging, around line 4992, and the conformance paragraph around line 4996) and specs/compiler-threat-detection-spec.md §7.9 (around lines 754 and 760) say files MUST stay 0600, guard-created subdirectories 0700, and modes MUST NOT be broadened. Update those sections and their conformance mapping in this PR, or keep the private modes and fix readability another way. - Make guarded safe-output assets readable by the uploader #75761 (comment)
  6. Review (actions/setup/js/symlink_guard.cjs:161): [/codebase-design] directoryMode applies to every ancestor this call creates, not just the asset and Claim directories. On a first run, parents such as gh-aw/ or safeoutputs/ above assets would be created 0755, which is broader than the private 0700 the spec requires for guard-created subdirectories. Apply the wider mode only to the leaf directories the caller needs, or document why the ancestors must be traversable. - Make guarded safe-output assets readable by the uploader #75761 (comment)
  7. Review (actions/setup/js/symlink_guard.cjs:239): [/codebase-design] mode and directoryMode accept any number, so a future caller could publish 0666 or 0777 through the guard. Restrict them to the two allowed pairs (0o600/0o700 and 0o644/0o755) and add a test that rejects other values. - Make guarded safe-output assets readable by the uploader #75761 (comment)
  8. Review (actions/setup/js/symlink_guard.test.cjs:175): [/tdd] This is the only test that reproduces the reported EACCES case, an unprivileged reader of root-owned staged assets. It is skipped unless the runner is root, so a non-root CI run has no cross-user coverage for this fix. Confirm a CI job runs it as root, or add a fixture that does not depend on the runner's uid. - Make guarded safe-output assets readable by the uploader #75761 (comment)
  9. Fix failing check safe_outputs (FAILURE): https://github.com/github/gh-aw/actions/runs/42423438587/job/128557900192.

Once you start work, post this work summary as a PR comment without the leading Copilot mention, including the Sous-chef head, work, and state lines below, to record that the assignment is running. Apply the necessary fixes on this PR's existing branch, reply to each listed review thread and resolve it when addressed. Ignore feedback already answered or resolved; stop when only human review or CI remains. Do not merge or trigger CI.

Sous-chef requested-head: 9d48a81
Sous-chef requested-work: 4c46a7c56548913e131a9245490a7623e86d40160888cbf43a56e6e47ccc37b1 5d32eda272e743618bfcb8019a7e23b217cc8de958f01756fa17ad45973de3e4 8a840250ba6271692cc774d8d49d05d1bdd313afeb68471dd848e9853ed3f204 8d3bb3537791d0bd82d830b38ba245d8741bef7e5a4900597d3fb09d35db87d4 a0cdfab9be0d8a9cc1e4a0974796a9ebab3d3f6972fca744ef85c031dca18f64 a372144b034b1f567cc6149e11caa847dc15e588391cc7b0f4ad2e186f4f1bb0 c7cf93e497befdd5e698d00101b0703e4101fe4133d86d433f7c170d07402b7e e767f5ada3f9cd31031ec3a41fc22896d642dd1229172cd2019dcea320a10478
Sous-chef requested-state: 1538f4bf5e5b66064af12fd4f6850bfb61d75942ac161d2d30d77a1aa8b77bdd

Generated by 👨🍳 PR Sous Chef · pi · haiku45 · ~10 AIC · ⌖ ~13 AIC · ⊞ 1.2K · ◷
Comment /souschef to run again

Copilot AI commented Nov 7, 2026

Copy link
Copy Markdown
Contributor Author

@copilot

Copilot assignment requested for the following outstanding work:...

Work summary: I’m updating this branch with main, restoring private guarded staging permissions while addressing uploader ownership/traversal, checking permission validation and CI coverage, and investigating the failing safe_outputs check. I’ll validate targeted tests, reply to actionable review threads, and stop without triggering CI.

Sous-chef requested-head: 9d48a81
Sous-chef requested-work: 4c46a7c56548913e131a9245490a7623e86d40160888cbf43a56e6e47ccc37b1 5d32eda272e743618bfcb8019a7e23b217cc8de958f01756fa17ad45973de3e4 8a840250ba6271692cc774d8d49d05d1bdd313afeb68471dd848e9853ed3f204 8d3bb3537791d0bd82d830b38ba245d8741bef7e5a4900597d3fb09d35db87d4 a0cdfab9be0d8a9cc1e4a0974796a9ebab3d3f6972fca744ef85c031dca18f64 a372144b034b1f567cc6149e11caa847dc15e588391cc7b0f4ad2e186f4f1bb0 c7cf93e497befdd5e698d00101b0703e4101fe4133d86d433f7c170d07402b7e e767f5ada3f9cd31031ec3a41fc22896d642dd1229172cd2019dcea320a10478
Sous-chef requested-state: 1538f4bf5e5b66064af12fd4f6850bfb61d75942ac161d2d30d77a1aa8b77bdd

…ssets-readable

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
@pelikhan
pelikhan merged commit 6ed730e into main Nov 8, 2026
103 checks passed
@pelikhan
pelikhan deleted the copilot/make-staged-assets-readable branch November 8, 2026 01:08
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v1.2.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[AW Top 10] 01 Make staged safe-output assets readable by uploader

4 participants